#coding:utf-8
from django.contrib import admin
from lovewith.website.models import Website, Link, Color, WeixinMp, Role, Category
from django.contrib.sites.models import Site


#站点选项
class WebsiteAdmin(admin.ModelAdmin):
    list_display = ('id', 'title', 'keyword', 'description')
    ordering = ('id',)


#友情连接管理
class LinkAdmin(admin.ModelAdmin):
    list_display = ('site_name', 'site_url', 'sort')
    ordering = ('sort',)


#预置颜色
class ColorAdmin(admin.ModelAdmin):
    list_display = ('sort', 'name', 'value')
    ordering = ('sort',)


#商家角色管理
class RoleAdmin(admin.ModelAdmin):
    list_display = ('name', 'sort')
    ordering = ('sort',)


#分类管理
class CategoryAdmin(admin.ModelAdmin):
    list_display = ('sort', 'cate_name', 'banner', 'keywords', 'description')
    ordering = ('sort',)

    def cate_name(self, obj):
        return '<a href="/share/cate/%s" target="_blank">%s</a>' % (obj.id, obj.name)

    cate_name.short_description = '名称'
    cate_name.allow_tags = True


#微信公众平台管理
class WeixinMpAdmin(admin.ModelAdmin):
    list_display = ('id', 'content')
    ordering = ('id',)



#注册显示model
admin.site.register(Website, WebsiteAdmin)
admin.site.register(Link, LinkAdmin)
admin.site.register(Color, ColorAdmin)
admin.site.register(WeixinMp, WeixinMpAdmin)
admin.site.register(Role, RoleAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.unregister(Site)